package com.jd.finance.core.controller.admin;


import com.jd.finance.core.service.NodeService;
import com.jd.finance.core.service.impl.AdminUtilsServiceImpl;
import com.jd.finance.result.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 菜单表(权限表) 前端控制器
 * </p>
 *
 * @author LiQingBo
 * @since 2022-05-20
 */
@Api(tags = "节点管理")
@Slf4j
@RestController
@RequestMapping("/admin/core/adminNodeCenter")
public class AdminNodeController {

    @Resource
    private NodeService nodeService;

    @Resource
    private AdminUtilsServiceImpl adminUtilsServiceimpl;

    @ApiOperation("根据uid查询菜单")
    @PostMapping("/getAdminList")
    public BaseResult getAdminList(Integer uid){
        if (uid == null){
            log.error("uid为空");
            return BaseResult.error().message("uid为空");
        }
        if (!adminUtilsServiceimpl.isAdmin(uid)){
            log.error("当前登录用户不是管理员账户");
            return BaseResult.error().message("当前登录用户不是管理员账户");
        }
        return nodeService.getAdminList(uid);
    }
}

